
package cn.edu.spark.core

import org.apache.spark.sql.SparkSession

import java.lang.Thread.sleep

object ExceptionHandlingTest {
  def main(args: Array[String]): Unit = {
    val spark = SparkSession
      .builder
      .master("local[*]")
      .appName("ExceptionHandlingTest")
      .getOrCreate()

    spark
      .sparkContext
      .parallelize(0 until spark.sparkContext.defaultParallelism).foreach { i =>
      if (math.random > 0.75) {
        throw new Exception("Testing exception handling")
      }
    }

    sleep(300000)
    spark.stop()
  }
}
